<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>vue图片预览</title>
  <link rel="stylesheet" href="../dist/vue-image-swipe.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.min.js"></script>
  <script src="../dist/vue-image-swipe.js"></script>
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    #app {
      position: absolute;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      background: #fff;
    }
    .wrap {
      margin: 0 auto;
      width: 100%;
      padding: 24px;
      box-sizing: border-box;
    }
    ul, li {
      list-style: none;
    }
    .picture-item {
      box-sizing: border-box;
      padding: 0 5px 10px;
    }
    .picture-nothumb {
      position: relative;
      padding-bottom: 100%;
      height: 0;
      background-color: #f9f9f9;
      overflow: hidden;
    }
    .picture-nothumb img {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%,-50%);
    }
    @media screen and (min-width: 641px) {
      .wrap {
        width: 640px;
      }
    }
  </style>
</head>
<body>
  <div id="app">
    <div class="wrap">
      <ul>
          <li
            class="picture-item"
            :key="index"
            @click="preview(index)"
            v-for="(l, index) in images">
              <div class="picture-nothumb">
                <img :src="l" alt="">
              </div>
          </li>
        </ul>
    </div>
  </div>
  <script>
    const vm = new Vue({
      el: '#app',
      data: {
        images: [
        'http://oayhezji6.bkt.clouddn.com/preview1.jpg',
        'http://oayhezji6.bkt.clouddn.com/preview2.jpg',
        'http://oayhezji6.bkt.clouddn.com/preview3.jpg',
        'http://oayhezji6.bkt.clouddn.com/preview9.jpg',
        'http://oayhezji6.bkt.clouddn.com/preview10.jpg',
        'http://oayhezji6.bkt.clouddn.com/preview6.jpg'
        ]
      },
      mounted() {
      },
      methods: {
        preview(index) {
          this.$imagePreview({
            images: this.images,
            index: index,
          })
        }
      }
    })
  </script>
</body>
</html>
